package com.zyz.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageInfo;
import com.zyz.common.ResultInfo;
import com.zyz.domain.Lesson;
import com.zyz.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
public class CourseController {

    @Autowired
    private CourseService courseService;

    @PostMapping("/course/queryCourses")
    public ResultInfo getPage(@RequestParam(value = "page",defaultValue = "1")Integer pageNum,
                              @RequestParam(value = "pageSize") Integer pageSize){
        PageInfo<Lesson> page=courseService.getPage(pageNum,pageSize);
        return ResultInfo.success(page);
    }
    @PostMapping("/course/addcourseToUser")
    public ResultInfo addLessonToUser(Integer id){
        courseService.addLessonToUser(id);
        return ResultInfo.success(null);
    }
    //判断是否选课
    @PostMapping("/course/checkToUser")
    public ResultInfo haveLesson(){
        String msg=courseService.haveLesson();
        return ResultInfo.success(msg);
    }
}
